package com.ssm.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

import com.ssm.model.User;
import com.ssm.service.UserService;

@Controller
public class UserController {
	@Autowired
	private UserService userService;
	@Autowired
	private User user;
	@RequestMapping(value = "/login", method = RequestMethod.POST)
	public String login(String name, String password) {
		if (name == null || password == null) {
			return "fail";
		}
		user.setName(name);
		user.setPassword(password);
		if (userService.canLogin(user)) {
			return "success";
		}
		return "fail";
	}

}
